﻿using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;

namespace Dsl.Ped.Common.Converters
{
    /// <summary>
    /// Converts null to <see cref="Visibility"/>
    /// </summary>
    public class NullToVisibilityConverter : IValueConverter
    {
        #region Implementation of IValueConverter

        /// <summary>
        /// Converts null value to <see cref="Visibility.Hidden"/>. Not null value is 
        /// converted to <see cref="Visibility.Visible"/>
        /// </summary>
        /// <returns><see cref="Visibility"/> of an object</returns>
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return value == null ? Visibility.Hidden : Visibility.Visible;
        }

        /// <summary>
        /// Backwards convertibility is not supported, an exception <see cref="NotImplementedException"/> is thrown
        /// </summary>
        /// <exception cref="NotImplementedException"></exception>
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}
